package com.fr.web;

import com.fr.report.TemplateWorkBook;
import com.fr.report.WorkBook;
import com.fr.report.io.TemplateImporter;
import com.fr.web.core.ShowWorkBookPolicy;
import java.io.InputStream;
import java.util.HashMap;
import java.util.Map;

public class EmbeddedTplReportlet extends Reportlet
{
  private String tplPath;
  private ShowWorkBookPolicy policy;
  private Map parameterMap;

  public EmbeddedTplReportlet(String paramString, ShowWorkBookPolicy paramShowWorkBookPolicy)
  {
    this(paramString, paramShowWorkBookPolicy, new HashMap());
  }

  public EmbeddedTplReportlet(String paramString, ShowWorkBookPolicy paramShowWorkBookPolicy, Map paramMap)
  {
    this.tplPath = paramString;
    this.policy = paramShowWorkBookPolicy;
    this.parameterMap = paramMap;
  }

  public TemplateWorkBook createReport(ReportletRequest paramReportletRequest)
    throws ReportletException
  {
    WorkBook localWorkBook;
    InputStream localInputStream;
    try
    {
      localInputStream = EmbeddedTplReportlet.class.getResourceAsStream(this.tplPath);
      localWorkBook = new TemplateImporter().generateTemplate(localInputStream);
      localInputStream.close();
    }
    catch (Exception localException)
    {
      throw new ReportletException(localException.getMessage(), localException);
    }
    return localWorkBook;
  }

  public void setPolicy(ShowWorkBookPolicy paramShowWorkBookPolicy)
  {
    this.policy = paramShowWorkBookPolicy;
  }

  public ShowWorkBookPolicy getPolicy()
  {
    return this.policy;
  }

  public void setParameterMap(Map paramMap)
  {
    this.parameterMap = paramMap;
  }

  public Map getParameterMap()
  {
    return this.parameterMap;
  }
}